// MyFamily - XML based genealogy program.
// Copyright (C) 2006  Doug Swisher
// See the file COPYING.txt for license details.

using System;
using System.Collections.Generic;
using System.Text;

namespace DataModel
{
    public class FamilyRelationship
    {
        // TODO - Doug - 9/5/2006 - this is a start on the list; there are lots of other possibilities
        public enum Relationship
        {
            Unknown,
            Mother, Father, Parent,
            Son, Daughter, Child,
            Brother, Sister, Sibling,
            Husband, Wife, Spouse
        };

        private Relationship relationship;
        private FamilyPersona from;
        private FamilyPersona to;


        public FamilyRelationship(Relationship relationship, FamilyPersona from, FamilyPersona to)
        {
            this.relationship = relationship;
            this.from = from;
            this.to = to;
        }


        private Relationship GetInverseRelationship()
        {
            // TODO - Doug - 9/5/2006 - implement this!
            return Relationship.Unknown;
        }


        public Relationship GetRelationship(FamilyPersona source)
        {
            if (source == this.from)
            {
                return this.relationship;
            }
            else if (source == this.to)
            {
                return this.GetInverseRelationship();
            }
            else
            {
                // TODO - Doug - 9/5/2006 - should this throw an exception?
                return Relationship.Unknown;
            }
        }


        public FamilyPersona GetOther(FamilyPersona source)
        {
            if (source == this.from)
            {
                return this.to;
            }
            else if (source == this.to)
            {
                return this.from;
            }
            else
            {
                // TODO - Doug - 9/5/2006 - should this throw an exception?
                return null;
            }
        }


        public FamilyPersona From
        {
            get { return this.from; }
        }


        public FamilyPersona To
        {
            get { return this.to; }
        }
    }
}
